﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web.Mvc;
using Ninject;


namespace HST.ZWParking.WebUI.Seedwork.IoC
{
    public class NinjectControllerFactory : DefaultControllerFactory
    {
        private IKernel kernel;
        public NinjectControllerFactory()
        {
            kernel = new StandardKernel();

            kernel.Bind<HST.Infrastructure.Data.Seedwork.IDatabaseFactory>().To<HST.ZWParking.Infrastructure.Data.EntityFramework.DatabaseFactory>();
            kernel.Bind<HST.Domain.Seedwork.IUnitOfWork>().To<HST.ZWParking.Infrastructure.Data.EntityFramework.UnitOfWork>();
            kernel.Bind<HST.ZWParking.Domain.Repositories.IProvinceRepository>().To<HST.ZWParking.Infrastructure.Data.EntityFramework.Repositories.ProvinceRepository>();
            kernel.Bind<HST.ZWParking.Application.Service.IProvinceService>().To<HST.ZWParking.Application.Service.Implementation.ProvinceService>();
        }

        protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
        {
            return controllerType == null
                ? null
                : (IController)kernel.Get(controllerType);
        }
    }
}
